package com.hd.controller;

import com.hd.pojo.InstrInfo;
import com.hd.pojo.ReservationInstr;
import com.hd.service.ReservationInstrService;
import com.hd.tools.Log;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by 1 on 2017/11/28.
 */
@RestController
@RequestMapping("/director/reservationInstroe")
public class ReservationInstrController {

    private String msg;

    @Resource
    private ReservationInstrService reservationInstrService;


    @RequestMapping("/searchInstrByDate")
    public String searchInstrByDate(String startDate,Integer instrId){
        List<InstrInfo> instrInfoList = reservationInstrService.searchInstrByDate(startDate,instrId);
        if(instrInfoList==null ||instrInfoList.size()==0){
            msg = "1";
        }else {
            msg = "0";
        }
        return msg;
    }

    @RequestMapping("/addRI")
    public String aa(ReservationInstr reservationInstr){
        System.out.println(reservationInstr.getReservationInstrStartDate());
        try{
            reservationInstrService.addRI(reservationInstr);
            msg = "预约成功!";
        }catch (Exception ex){
            msg = "预约失败!";
            Log.logger.error(msg,ex);
        }
        return msg;
    }



}
